/**
    @author: administrator
    @date:   2020/12/4
    @note:
**/
package server

import (
	"encoding/json"
	"net/http"
	"path/filepath"
)

//获取用户头像列表
func GetAvaterList(w http.ResponseWriter,r *http.Request){
	//允许跨域
	w.Header().Set("Access-Control-Allow-Origin", "*")

	//获取指定目录下的所有文件
	files,_:=filepath.Glob("image/avatar/*.jpg")
	var ret []string
	for _,file:=range files{
		ret = append(ret,"http://"+r.Host+"/avatar/"+filepath.Base(file))
	}
	retJson,_:=json.Marshal(ret)
	w.Write(retJson)
	return
}
